﻿@using Webdiyer.WebControls.Mvc
@model  Webdiyer.WebControls.Mvc.PagedList<LoveEat.MODEL.shop_menu>
    <div class="cont" id="listdata">
        @if (Model != null)
        {
            <table class="table table-responsive table-hover table-striped table-bordered">
                <thead>
                    <tr>
                        <th>

                            <input id="all" name="checkbox1" type="checkbox" value="" onclick="checkboxUdp()" />
                        </th>

                        <th width="6.7">编号</th>
                        <th width="40%">菜品系列</th>
                        <th width="40%">价格</th>
                        <th width="40%">菜品名称</th>
                        <th width="40%">店铺</th>
                        <th width="50">操作</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var item in Model)
                    {
                        <tr>
                            <td width="20">  <input type="checkbox" name="checkbox" value="@item.menu_id" /></td>
                            <td width="100">@item.menu_id</td>
                            <td width="100">@item.SeriesName</td>
                            <td width="100">@item.price</td>
                            <td>@item.menu_name</td>
                            <td>@item.ShopName</td>
                            <td width="100">
                                <a class="btn blue mini" href='@Url.Action("ShopMenuEdit", new { menu_id = item.menu_id, returnUrl = Request.Url })'><i class="icon-edit">编辑</i></a>
                                <a class="btn purple mini" href='@Url.Action("DeleteShopMenu", new { menu_id = item.menu_id, returnUrl = Request.Url.PathAndQuery })'>删除</a>
                            </td>
                        </tr>

                    }

                </tbody>
            </table>

            <div class="row-fluid">
                @if (Model != null)
                {
                    <div class="span3" id="pagedata">
                        <div class="dataTables_info">共 @Model.TotalItemCount 记录,共 @Model.TotalPageCount 页 </div>
                    </div>

                    <div class="span9">
                        @Ajax.Pager(Model, new PagerOptions { PageIndexParameterName = "PageIndex", ShowPageIndexBox = false, PageIndexBoxType = PageIndexBoxType.DropDownList, ShowGoButton = true, CurrentPagerItemWrapperFormatString = "<a class=\"active\">{0}</a>" }, new MvcAjaxOptions { UpdateTargetId = "listdata", HttpMethod = "Post", DataFormId = "searchform" })

                    </div>
                }
            </div>

        }

        else
        {
            <table class="table table-responsive table-hover table-striped table-bordered">
                <thead>
                    <tr>
                        <th>

                            <input id="all" name="checkbox1" type="checkbox" value="" onclick="checkboxUdp()" />
                        </th>

                        <th width="6.7">编号</th>
                        <th width="7%">菜品类型</th>
                        <th width="40%">菜品系列</th>
                        <th width="50">操作</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
            <div style="  text-align: center;">
                暂无数据
            </div>

        }
    </div>




    <script type="text/javascript">

        //Checkbox全选
        function checkboxUdp() {
            var oInput = document.getElementsByName("checkbox");
            for (var i = 0; i < oInput.length; i++) {
                if (document.getElementById("all").checked == true) {
                    oInput[i].checked = true;
                }
                else {
                    oInput[i].checked = false;
                }
            }
        }


        //批量删除
        function BatchDel() {

            var num = 0;
            if ($('input[name="checkbox"]:checked').val() == undefined) {
                $.alert.defaulta('提示', '请选择删除的列');
            }
            else {
                var id = "";
                $.alert.confirm('删除', '是否删除?', function () {
                    $('input[name="checkbox"]:checked').each(function () {
                        id += $(this).val() + ',';
                    });


                    if (id != "") {

                        $.ajax({
                            url: "/MenuManagement/DeleteShopMenuList",
                            type: "post",
                            data: { Id: id },
                            success: function (data) {

                                if (data > 0) {
                                    $.alert.defaulta('提示', '删除成功', function () {
                                        location.reload();
                                    });

                                }
                                else {
                                    $.alert.defaulta('提示', '删除失败');
                                }

                            }
                        });
                    }
                    else {
                        $.alert.defaulta('提示', '请选择删除的列');

                    }
                });
            }
        }





    </script>











